admin: restore current-etc symlink
authorGiovanni Campagna <gcampagna@src.gnome.org>
Fri, 21 Dec 2012 23:21:28 +0000 (00:21 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Wed, 26 Dec 2012 18:42:46 +0000 (19:42 +0100)
It is useful now like it was before, and it is used by the grub
update script.

https://bugzilla.gnome.org/show_bug.cgi?id=690743

src/ostree/ot-admin-builtin-deploy.c

index d870a990669bf9107dfa456cc12454ab77b7c429..588b6a95827286e6d4496cbca3ad1f4cc2c8d87c 100644 (file)
@@ -65,8 +65,10 @@ update_current (OtAdminDeploy      *self,
 {
   gboolean ret = FALSE;
   ot_lobj GFile *current_path = NULL;
+  ot_lobj GFile *current_etc_path = NULL;
   ot_lobj GFile *previous_path = NULL;
   ot_lobj GFile *tmp_current_path = NULL;
+  ot_lobj GFile *tmp_current_etc_path = NULL;
   ot_lobj GFile *tmp_previous_path = NULL;
   ot_lobj GFileInfo *previous_info = NULL;
   ot_lfree char *relative_current = NULL;
@@ -74,6 +76,7 @@ update_current (OtAdminDeploy      *self,
   ot_lfree char *relative_previous = NULL;
 
   current_path = g_file_get_child (self->osname_dir, "current");
+  current_etc_path = g_file_get_child (self->osname_dir, "current-etc");
   previous_path = g_file_get_child (self->osname_dir, "previous");
 
   relative_current = g_file_get_relative_path (self->osname_dir, deploy_target);
@@ -112,9 +115,20 @@ update_current (OtAdminDeploy      *self,
       goto out;
     }
 
+  tmp_current_etc_path = g_file_get_child (self->osname_dir, "tmp-current-etc");
+  (void) gs_file_unlink (tmp_current_etc_path, NULL, NULL);
+  if (symlink (relative_current_etc, gs_file_get_path_cached (tmp_current_etc_path)) < 0)
+    {
+      ot_util_set_error_from_errno (error, errno);
+      goto out;
+    }
+
   if (!gs_file_rename (tmp_current_path, current_path,
                        cancellable, error))
     goto out;
+  if (!gs_file_rename (tmp_current_etc_path, current_etc_path,
+                       cancellable, error))
+    goto out;
 
   if (tmp_previous_path)
     {